<?php if((arg(1) == 'edit'|| arg(1) == "add") && !empty($_GET['farmer_id'])) {
    echo get_template_header_info($form['#farmer']);
}?>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
    <img style="margin-left: 85px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }?>
    <ul class="j-sw-nav">
        <?php if (arg(1) == "add" && empty($_GET['farmer_id'])) { ?>
            <li class="newprd-s1 tab-li"><a href="<?php echo base_path();?>gift/list">查看</a></li>
            <?php if(user_access('manage gift')){ ?>
                <li class="newprd-s2 tab-li on"><a href="<?php echo base_path();?>gift/add">添加</a></li>
            <?php }
        } else if ((arg(1) == "add" && !empty($_GET['farmer_id'])) || (arg(1) == "edit" && !empty($_GET['farmer_id']))) {?>
            <?php echo get_tab($form['#farmer'],'gift'); ?>
        <?php }
        else if(arg(1) == "edit" && empty($_GET['farmer_id'])){?>
            <li class="newprd-s1 tab-li"><a href="<?php echo base_path();?>gift/list">查看</a></li>
            <?php if(user_access('manage gift')){ ?>
                <li class="newprd-s2 tab-li"><a href="<?php echo base_path();?>gift/add">添加</a></li>
            <?php }?>
            <li class="newprd-s3 tab-li on"><a>修改</a></li>
        <?php }?>
    </ul>
    <div class="table-div">
        <div class="small-select small-input column" style="clear:both">
            <?php global $user;
            $user_info = _get_user_info($user->uid);
            if(get_user_role_name($user->uid) === '农户') {?>
                <?php print render($form['farmer']); ?>
            <?php }else if(empty($_GET['farmer_id'])){?>
                <div class="small-input address-search">
                    <div class="form-label"><span class="required">*</span>农户:</div>
                    <?php print render($form['farmer_name']);
                    if(empty($form['#gift_id'])){
                        print render($form['select_farmer_button']);
                    }
                    ?>
                </div>
            <?php }?>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label"><span class="required">*</span>礼物类型:</div><?php print render($form['gift']['gift_type']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="form-label"><span class="required">*</span>赠送数量:</div><?php print render($form['gift']['quantity']); ?>
        </div>
        <div class="small-select max-big-input column" style="clear:both">
            <div class="form-label">专项活动:</div><?php print render($form['special_activities']); ?>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="form-label">备注:</div><div style="margin-left: 11.3em; "><?php print render($form['gift']['comments']); ?></div>
        </div>
        <div class="add-submit" style="text-align: center"><?php print render($form['submit']); ?></div>
        <?php if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
            <ul class="table-ul-li">
                <li style=" padding: 2em 0;  float: right; margin-top: -5.8em;margin-right: 24em;  float: right; margin-top: -5.8em;margin-right: 24em;"><a href="<?php echo base_path(); ?>gift/list?farmer_id=<?php echo $form['#farmer']?>">
                        <input class="btn btn-primary form-submit" type="button"  value="返回">
                    </a></li>
<!--                --><?php //if(user_access('manage gift')){ ?>
<!--                    <li>|</li>-->
<!--                    <li><a href="--><?php //echo base_path(); ?><!--gift/add?farmer_id=--><?php //echo $form['#farmer']?><!--" --><?php //if(arg(1) == "add" && !empty($_GET['farmer_id'])){?><!--class="selected"--><?php //}?><!--添加</a></li>-->
<!--                --><?php //}
//                if(arg(1) == "edit" && !empty($_GET['farmer_id'])){?>
<!--                    <li>|</li>-->
<!--                    <li class="selected">详情</li>-->
<!--                --><?php //}?>
            </ul>
        <?php }?>
    </div>
</div>

<?php print drupal_render_children($form); ?>
</div></form>

<div>
    <div class="modal fade" id="farmerModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        选择农户
                    </h4>
                </div>
                <div class="modal-body">
                    <?php echo @render(drupal_get_form('farmer_select_list_form',$_GET['addr_id']?$_GET['addr_id']:''));?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<form><div>
